#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
typedef struct SString
{
	int len;
	char ch[20];
}SString;


int StrDelete(SString* s, int pos, int len)
/*在串s中删除从下标pos起len个字符*/
{
	int i;
	if (pos<0 || pos>(s->len - len))/*删除参数不合法*/
		return(0);
	for (i = pos + len; i < s->len; i++)
		s->ch[i - len] = s->ch[i]; /*从pos+len开始至串尾依次向前移动，实现删除len个字符*/
	s->len = s->len - len; /*s串长减len*/
	s->ch[s->len] = '\0';
	return(1);
}

void createstring(SString* str)
{
	gets(str->ch);
	str->len=strlen(str->ch);
}

void output(SString*str)
{
	printf("%s", str->ch);
}
void main()
{
	SString* str1;
	int j, pos;
	int flag = 0;
	str1 = (SString*)malloc(sizeof(SString));
	str1->len = 0;
	printf("建立字符串1:\n");
	createstring(str1);
	printf("请输入删除位置和长度:\n");
	//fflush(stdin);
	scanf("%d,%d", &pos, &j);
	flag = StrDelete(str1, pos, j);
	if (flag == 0)
		printf("删除操作失败!");
	else
	{
		printf("删除后串为:\n");
		output(str1);
	}